﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Serialization;

using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;


namespace FastPMOSite.FastSharePointReportsViewer
{
    [XmlRootAttribute("FastPMOSite")]
    public class FastSharePointReportsViewer : Microsoft.SharePoint.WebPartPages.WebPart
    {
        private const string defaultUrl = "";
        private string url = defaultUrl;



        [WebPartStorage(Storage.Shared),
        Personalizable(PersonalizationScope.Shared),
        Category("FastSharePoint"),
        Description("Enter the URL for the FastSharePoint report or chart."),
        FriendlyNameAttribute("ChartUrl"),
        WebBrowsable(true)]
        public string ChartURL
        {
            get
            {
                return url;
            }
            set
            {
                url = value;
            }
        }


        public FastSharePointReportsViewer()
        {
        }

        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            // TODO: add custom rendering code here.
            // Label label = new Label();
            // label.Text = "Hello World";
            // this.Controls.Add(label);
        }

        protected override void Render(HtmlTextWriter writer)
        {
            this.EnsureChildControls();

            writer.Write("<iframe src=\"" + url + "\" width=\"100%\" height=\"100%\" frameborder=\"0\"></iframe>");
        }
    }
}
